﻿using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

// Token: 0x020001E9 RID: 489
public class ItemSelectUISets
{
	// Token: 0x06000CF4 RID: 3316 RVA: 0x0004DC6C File Offset: 0x0004BE6C
	public ItemSelectUISets(EditMode editMode, GameObject toggleParent, MoveableThumbnailSelectUI selectUI, string title, List<CustomSelectSet> setDatas, UnityAction<CustomSelectSet> act)
	{
		this.title = title;
		this.act = act;
		this.setDatas = setDatas;
		this.toggle = editMode.CreateItemToggle(toggleParent);
		this.select = selectUI;
		this.select.gameObject.SetActive(false);
		this.toggle.Setup(title, this.select);
		this.toggle.toggle.onValueChanged.AddListener(new UnityAction<bool>(this.SetupSelect));
	}

	// Token: 0x06000CF5 RID: 3317 RVA: 0x0004DCF8 File Offset: 0x0004BEF8
	private void SetupSelect(bool flag)
	{
		if (flag)
		{
			this.select.Setup(this.title, this.setDatas, new UnityAction<MoveableUI.STATE>(this.toggle.OnChangeState), new UnityAction<CustomSelectSet>(this.OnChange));
			this.select.SetSelectedFromDataID(this.selectID);
		}
	}

	// Token: 0x06000CF6 RID: 3318 RVA: 0x0004DD50 File Offset: 0x0004BF50
	public void ChangeDatas(List<CustomSelectSet> setDatas, bool resetSelectID)
	{
		if (resetSelectID)
		{
			this.selectID = -1;
		}
		this.setDatas = setDatas;
		this.select.Setup(this.title, setDatas, new UnityAction<MoveableUI.STATE>(this.toggle.OnChangeState), new UnityAction<CustomSelectSet>(this.OnChange));
		this.select.SetSelectedFromDataID(this.selectID);
		this.select.UpdateEnables();
		CustomSelectSet data = (!resetSelectID) ? this.GetSelectedData(this.selectID) : null;
		this.toggle.ApplyFromData(data);
	}

	// Token: 0x06000CF7 RID: 3319 RVA: 0x0004DDE4 File Offset: 0x0004BFE4
	private void OnChange(CustomSelectSet set)
	{
		if (set != null)
		{
			this.selectID = set.id;
		}
		else
		{
			this.selectID = -1;
		}
		this.toggle.OnSelectChange();
		if (this.act != null)
		{
			this.act(set);
		}
	}

	// Token: 0x06000CF8 RID: 3320 RVA: 0x0004DE34 File Offset: 0x0004C034
	public void SetSelectedFromDataID(int id)
	{
		this.selectID = id;
		this.toggle.ApplyFromData(this.GetSelectedData(this.selectID));
	}

	// Token: 0x06000CF9 RID: 3321 RVA: 0x0004DE54 File Offset: 0x0004C054
	public void SetSelectedNo(int no)
	{
		if (no >= 0 && no < this.setDatas.Count)
		{
			this.selectID = this.setDatas[no].id;
		}
		else
		{
			this.selectID = -1;
		}
		this.toggle.ApplyFromData(this.GetSelectedData(this.selectID));
	}

	// Token: 0x06000CFA RID: 3322 RVA: 0x0004DEB4 File Offset: 0x0004C0B4
	public CustomSelectSet GetSelectedData(int id)
	{
		if (this.setDatas == null)
		{
			return null;
		}
		for (int i = 0; i < this.setDatas.Count; i++)
		{
			if (this.setDatas[i].id == id)
			{
				return this.setDatas[i];
			}
		}
		return null;
	}

	// Token: 0x06000CFB RID: 3323 RVA: 0x0004DF10 File Offset: 0x0004C110
	public CustomSelectSet GetSelectedData()
	{
		return this.GetSelectedData(this.selectID);
	}

	// Token: 0x06000CFC RID: 3324 RVA: 0x0004DF20 File Offset: 0x0004C120
	public List<CustomSelectSet> GetDatas()
	{
		return this.setDatas;
	}

	// Token: 0x06000CFD RID: 3325 RVA: 0x0004DF28 File Offset: 0x0004C128
	public void ApplyFromID(int id)
	{
		this.selectID = id;
		this.toggle.ApplyFromData(this.GetSelectedData(this.selectID));
	}

	// Token: 0x06000CFE RID: 3326 RVA: 0x0004DF48 File Offset: 0x0004C148
	public void ApplyFromSelectedData()
	{
		this.toggle.ApplyFromData(this.GetSelectedData(this.selectID));
	}

	// Token: 0x04000D50 RID: 3408
	public ItemChangeToggle toggle;

	// Token: 0x04000D51 RID: 3409
	public MoveableThumbnailSelectUI select;

	// Token: 0x04000D52 RID: 3410
	private UnityAction<CustomSelectSet> act;

	// Token: 0x04000D53 RID: 3411
	private List<CustomSelectSet> setDatas;

	// Token: 0x04000D54 RID: 3412
	private int selectID = -1;

	// Token: 0x04000D55 RID: 3413
	private string title;
}
